package com.atguigu.exam;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.format.DateTimeFormatter;
import java.time.temporal.TemporalAccessor;

/**
 * @author xbd
 * @create 2021-05-25 16:22
 */
public class TransTest {
    public static void main(String[] args) throws ParseException {
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
        java.util.Date date = simpleDateFormat.parse("2017-08-16");
        java.sql.Date get = new java.sql.Date(date.getTime());
        System.out.println("解析后：" + date);
        System.out.println("转化为sql后：" + get);

        DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
        TemporalAccessor date1 = dateTimeFormatter.parse("2017-08-16");
        System.out.println(date1);


    }
}
